home *** CD-ROM | disk | FTP | other *** search
- .po 0
- [LISTING ONE]
-
-
- /* [Excerpted from /sys/i386/include/param.h] */
- ...
- #ifndef __ORPL__
- /* Interrupt Group Masks */
- extern u_short __highmask__; /* interrupts masked with splhigh() */
- extern u_short __ttymask__; /* interrupts masked with spltty() */
- extern u_short __biomask__; /* interrupts masked with splbio() */
- extern u_short __netmask__; /* interrupts masked with splimp() */
- extern u_short __protomask__; /* interrupts masked with splnet() */
- extern u_short __nonemask__; /* interrupts masked with splnone() */
-
- asm(" .set IO_ICU1, 0x20 ; .set IO_ICU2, 0xa0 ");
-
- /* adjust priority level to disable a group of interrupts */
- #define __ORPL__(m) ({ u_short oldpl, msk; \
- msk = (msk); \
- asm volatile (" \
- cli ; /* modify interrupts atomically */ \
- movw %1, %%dx ; /* get mask to OR in */ \
- inb $ IO_ICU1+1, %%al ; /* get low order mask */ \
- xchgb %%dl, %%al ; /* switch the old with the new */ \
- orb %%dl, %%al ; /* finally, OR both it in! */ \
- outb %%al, $ IO_ICU1+1 ; /* and stuff it back where it came */ \
- inb $ 0x84, %%al ; /* post it & handle write recovery */ \
- inb $ IO_ICU2+1, %%al ; /* next, get high order mask */ \
- xchgb %%dh, %%al ; /* switch the old with the new */ \
- orb %%dh, %%al ; /* finally, or it in! */ \
- outb %%al, $ IO_ICU2+1 ; /* and stuff it back where it came */ \
- inb $ 0x84, %%al ; /* post it & handle write recovery */ \
- movw %%dx, %0 ; /* return old mask */ \
- sti /* allow interrupts again */ " \
- : "&=g" (oldpl) /* return values */ \
- : "g" ((m)) /* arguments */ \
- : "ax", "dx" /* registers used */ \
- ); \
- oldpl; /* return the "old" value */ \
- })
- /* force priority mask to a set value */
- #define __SETPL__(m) ({ u_short oldpl, msk; \
- msk = (msk); \
- asm volatile (" \
- cli ; /* modify interrupts atomically */ \
- movw %1, %%dx ; /* get mask to OR in */ \
- inb $ IO_ICU1+1, %%al ; /* get low order mask */ \
- xchgb %%dl, %%al ; /* switch the old with the new */ \
- outb %%al, $ IO_ICU1+1 ; /* and stuff it back where it came */ \
- inb $ 0x84, %%al ; /* post it & handle write recovery */ \
- inb $ IO_ICU2+1, %%al ; /* next, get high order mask */ \
- xchgb %%dh, %%al ; /* switch the old with the new */ \
- outb %%al, $ IO_ICU2+1 ; /* and stuff it back where it came */ \
- inb $ 0x84, %%al ; /* post it & handle write recovery */ \
- movw %%dx, %0 ; /* return old mask */ \
- sti /* allow interrupts again */ " \
- : "&=g" (oldpl) /* return values */ \
- : "g" ((m)) /* arguments */ \
- : "ax", "dx" /* registers used */ \
- ); \
- oldpl; /* return the "old" value */ \
- })
- #define splhigh() __ORPL__(__highmask__)
- #define spltty() __ORPL__(__ttymask__)
- #define splbio() __ORPL__(__biomask__)
- #define splimp() __ORPL__(__netmask__)
- #define splnet() __ORPL__(__protomask__)
- #define splsoftclock() __ORPL__(__protomask__)
- #define splx(v) ({ u_short val; \
- val = (v); \
- if (val == __nonemask__) (void) spl0(); /* zero is special */ \
- else (void) __SETPL__(val); \
- })
- #endif __ORPL__
- ...
-
-